import { InputType } from '@/utils';

export const searchConfig: PageConfig = {
    items: [
        {
            itemType: 'text',
            modelKey: 'deviceCode',
            elInputProps: {
                placeholder: '请输入设备编码'
            },
            columnProps: {
                label: '设备编码',
                labelWidth: '72px'
            },
            validFormatType: InputType.NUMERIC_ALPHABET_SYMBOLS
        },
        {
            itemType: 'date',
            modelKey: 'month',
            elDatePickerProps: {
                type: 'month',
                valueFormat: 'YYYY-MM',
                placeholder: '请选择月份',
                disabledDate: (date: Date) => {
                    const year = new Date().getFullYear();
                    const month = new Date().getMonth();
                    const now = new Date(year, month, 1);
                    // 当前时间大于传入时间禁用
                    if (date < now) return true;
                    const targetDate = new Date(year, 6, 1);

                    // 如果当前时间小于6.30
                    if (now < targetDate) {
                        // 禁用今年以后全部时间
                        return new Date(year + 1, 0, 0) < date;
                    } else {
                        // 如果时间大于6.30

                        // 禁用明年以后全部时间
                        return new Date(year + 2, 0, 0) < date;
                    }
                    //
                }
            },
            columnProps: {
                label: '月份',
                labelWidth: '50px'
            }
        }
    ]
};
